import React from 'react';
import { Router, Route, Switch, Redirect } from 'dva/router';
import { LocaleProvider } from 'antd';
import zhCN from 'antd/lib/locale-provider/zh_CN';
import BasicLayout from './layouts/BasicLayout';
import UserLayout from './layouts/UserLayout';
import Service from './routes/service/Service';
import {requireAuthentication} from './utils/requireAuthentication';

function RouterConfig({ history }) {
    return (
        <LocaleProvider locale={zhCN}>
            <Router history={history}>
                <Switch>
                    <Route path="/user" component={UserLayout} />
                    <Route path="/service" component={Service} />
                    <Route path="/" component={requireAuthentication(BasicLayout)} />
                    <Redirect to="/" />
                </Switch>
            </Router>
        </LocaleProvider>
    );
}

export default RouterConfig;
